Programming Guide
This programming guide serves as a reference on how to go about using the included api.
Steps
- Drag the files into your project and import them into your source file using, #import “JOEModelManager.h”
- Instantiate the singleton and load the model file by calling [[JOEModelManager sharedManager] load];
- Create objects that conform to NSCoding and add them by calling [[JOEModelManager sharedManager] addObject:object];
- Get objects by calling [[JOEModelManager sharedManager] objectAtIndex:index]; // index is the objects place in the array
- Remove objects by calling [[JOEModelManager sharedManager] removeObject:object];
- Save objects to disk by calling [[JOEModelManager sharedManager] save];
App Delegate Example
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
NSLog(@"DidFinishLaunching");
// Override point for customization after application launch.
ViewController *viewController = (ViewController *)self.window.rootViewController;
// Initialize the shared model manager to perform data modeling tasks
BOOL success = [[JOEModelManager sharedManager] load];
if (!success) {
// This is a brand new user, let's introduce them!
// You could use this functionality to instantiate an Introduction View Controller
viewController.myObject = [[MyObject alloc] initWithText:@"Welcome New User!"];
[[JOEModelManager sharedManager] addObject:viewController.myObject];
[[JOEModelManager sharedManager] save];
}else {
// This user has existing data. Get straight to work.
// Here you would instantiate the main part of the app or just do work.
viewController.myObject = [[JOEModelManager sharedManager] objectAtIndex:0];
}
return YES;
}